import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
import os

class MouseOption:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://sahitest.com/demo/clicks.htm')
        time.sleep(1)
        self.driver.maximize_window()
        self.ac = ActionChains(self.driver)
    def click(self):
        # btn=self.driver.find_element(By.XPATH,'//form/input[3]')
        # btn.click()
        button1 = self.driver.find_element(By.CSS_SELECTOR,'form input:nth-of-type(3)')
        self.ac.click(button1).perform()
        time.sleep(3)
    def doubleclick(self):
        button2 = self.driver.find_element(By.CSS_SELECTOR,'form>div+input')
        self.ac.double_click(button2).perform()
        time.sleep(2)
    def drag(self):
        self.driver.get('https://sahitest.com/demo/dragDropMooTools.htm')
        source = self.driver.find_element(By.CSS_SELECTOR,'div')
        target = self.driver.find_elements(By.CSS_SELECTOR,'div')
        self.ac.drag_and_drop(source,target[-1]).perform()
        time.sleep(2)
    def moveover(self):
        time.sleep(2)
        self.driver.get('https://sahitest.com/demo/mouseover.htm')
        button3 = self.driver.find_element(By.XPATH,'//input')
        self.ac.move_to_element(button3).perform()
        time.sleep(2)
    def click_hold(self):
        url ='file:///C:/Users/1/Desktop/qd/html/mouse_hold.html'
        self.driver.get(url)
        time.sleep(2)
        but4 = self.driver.find_element(By.ID,'btn1')
        self.ac.click_and_hold(but4).perform()
        time.sleep(4)




case = MouseOption()
# case.doubleclick()
case.click_hold()



